package com.sp2.dev.apachecommons;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: zhimingli
 * Date: 14-2-17
 * Time: 上午11:17
 * To change this template use File | Settings | File Templates.
 */
public class PoliticalCandidate {
    private String firstName;

    private String lastName;

    private Date dateOfBirth;

    private BigDecimal bigDecimal;

    private Usercommon usercommon;

    public PoliticalCandidate(String firstName, String lastName, Date dateOfBirth, BigDecimal bigDecimal, Usercommon usercommon) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.dateOfBirth = dateOfBirth;
        this.bigDecimal = bigDecimal;
        this.usercommon = usercommon;
    }

    @Override
    public String toString() {
        //com.sp2.dev.apachecommons.PoliticalCandidate@8813f2
        // [firstName=firstName,lastName=lastName,dateOfBirth=Mon Feb 17 11:41:42 CST 2014,bigDecimal=111]
        return ReflectionToStringBuilder.toString(this, ToStringStyle.DEFAULT_STYLE);
    }

    public static void main(String[] args) {
        Usercommon usercommon = new Usercommon("name",9999);
        PoliticalCandidate politicalCandidate = new PoliticalCandidate("firstName","lastName",new Date(),new BigDecimal(111),usercommon);
        System.out.println(politicalCandidate);

        //hashcode and euqals
        Usercommon u1 = new Usercommon("name",9999);
        Usercommon u2 = new Usercommon("name",9999);
        System.out.println(u1==u2);
        System.out.println(u1.equals(u2));
    }

}
